
$(function() {
	var _vv_option = {
		rules: {
			name: {
				remote: "contact.php?do=Supplier.ajax_exist1",
				required: true
			},
		
			fullname: {
				remote: "contact.php?do=Supplier.ajax_exist2",
				required: true
			}
		},
		messages: {
			name: {
				remote: jQuery.format("{0} 已经存在")
			},
			fullname: {
				remote: jQuery.format("{0} 已经存在")
			}
		},
		errorPlacement: function(label, element) {
			label.insertAfter(element);
		},
		success: function(label) {
			label.html("&nbsp;").addClass("checked");
		}
	};	
	
	validator = $("#form_add").validate(_vv_option);

	$("select[name=category_t]:visible").selectChain({
		target: $("select[name=type_t]:visible"),
		key: "code",
		value: "name",
		url: 'contact.php?do=Supplier.ajax_category',
		data: { ajax: true }
	}).trigger('change');

	$("select[name=category_t]:visible").change(function() {
		var s = $("select[name=category_t]:visible").val();
		if (s != null && s != '-')　{
			$("input[name=category]:visible").val(s);
		}		
	});
	 
	_change("input[id='type']:visible", "select[id^='type_t']:visible");
	
	_change("input[id='pay']:visible", "select[id^='pay_t']:visible");
	
	$("input[name=emp]:visible").autocomplete(Test.emp);
	
	_ck_default("input[id='emp']:visible", "input[id^='emp_t']:visible");

	$('textarea').css("width", 400);
});
